Builder

class Builder<K : Enum<*>, V : Any>

Builds a ValidatedEnumMap

Not strictly necessary, but may make construction cleaner.

Author

fzzyhmstrs

Since

0.2.0

Parameters

K

key type, needs to be Enum and Translatable

V

value type. any non-null type.

Samples

import me.fzzyhmstrs.fzzy_config.util.Translatable
import me.fzzyhmstrs.fzzy_config.validation.collection.ValidatedEnumMap
import me.fzzyhmstrs.fzzy_config.validation.collection.ValidatedIdentifierMap
import me.fzzyhmstrs.fzzy_config.validation.collection.ValidatedStringMap
import me.fzzyhmstrs.fzzy_config.validation.minecraft.ValidatedIdentifier
import me.fzzyhmstrs.fzzy_config.validation.misc.ValidatedBoolean
import me.fzzyhmstrs.fzzy_config.validation.misc.ValidatedString
import me.fzzyhmstrs.fzzy_config.validation.number.ValidatedFloat
import me.fzzyhmstrs.fzzy_config.validation.number.ValidatedInt
import net.minecraft.registry.tag.ItemTags
import net.minecraft.util.Identifier
import java.util.*

fun main() { 
   //sampleStart 
   // a ValidatedEnumMap built with the Builder.
// KeyHandler automatically builds a ValidatedEnum of the enum class of the default passed
// valueHandler takes any Entry, in this case a ValidatedFloat
// defaults builds the default map. In this case out of vararg set of Pair<Enum, V>
val enumTest: ValidatedEnumMap<TestEnum, Float> =
    ValidatedEnumMap.Builder<TestEnum, Float>()
        .keyHandler(TestEnum.TEST)
        .valueHandler(ValidatedFloat(1f, 1f, 0f))
        .defaults(TestEnum.TEST to 1f, TestEnum.EVEN to 0.6f, TestEnum.ODDS to 0.5f)
        .build()

//An EnumMap builder using an empty EnumMap as default
val enumEnumMapTest: ValidatedEnumMap<TestEnum, Float> =
    ValidatedEnumMap.Builder<TestEnum, Float>()
        .keyHandler(TestEnum.TEST)
        .valueHandler(ValidatedFloat(1f, 1f, 0f))
        .defaults(EnumMap(TestEnum::class.java))
        .build() 
   //sampleEnd
}

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
class BuilderWithKey<K : Enum<*>, V : Any>

Functions

Link copied to clipboard

Defines the Entry used to handle validation, serialization, etc. for map values

Defines the Entry used to handle validation, serialization, etc. for map keys